<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
    <h2>异常捕获</h2>

    <!-- try-catch:捕获异常 
    try里面的代码如果没有错误，catch是不会被触发的
    try-catch可以当代码 更健壮（即使报错，依然会执行后续代码，负重前行）
    js里面如果出错 后面的代码不会继续执行 -->

    <script>
      async function getInfo() {
        try {
          const result = await axios({
            url: 'http://ajax-api.itheima.net/api/books/69',
          })
          console.log('result', result)
        } catch (err) {
          console.log('err', err)
        }

        console.log(333) // 一定会打印
      }
      getInfo()

      try {
        console.log(data)
      } catch (err) {
        console.log(err)
      }
      console.log(111)
    </script>
  </body>
</html>
